home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November A / PCWK1103A.iso / ABBYY FineReader 7.0 PRO / data1.cab / gs_btokn.ps < prev    next >
Text File  |  2002-02-23  |  11KB  |  321 lines

  1. %    Copyright (C) 1994, 2000 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_btokn.ps,v 1.5.2.1 2002/02/22 19:45:55 ray Exp $
  14. % Initialization file for binary tokens.
  15. % When this is run, systemdict is still writable,
  16. % but everything defined here goes into level2dict.
  17.  
  18. % Define whether or not to allow writing dictionaries.
  19. % This is a non-standard feature!
  20. /WRITEDICTS false def
  21.  
  22. languagelevel 1 .setlanguagelevel
  23. level2dict begin
  24.  
  25. % Initialization for the system name table.
  26.  
  27. mark
  28. % 0
  29.     /abs /add /aload /anchorsearch /and
  30.     /arc /arcn /arct /arcto /array
  31.     /ashow /astore /awidthshow /begin /bind
  32.     /bitshift /ceiling /charpath /clear /cleartomark
  33. % 20
  34.     /clip /clippath /closepath /concat /concatmatrix
  35.     /copy /count /counttomark /currentcmykcolor /currentdash
  36.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  37.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  38. % 40
  39.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  40.     /cvlit /cvn /cvr /cvrs /cvs
  41.     /cvx /def /defineusername /dict /div
  42.     /dtransform /dup /end /eoclip /eofill
  43. % 60
  44.     /eoviewclip /eq /exch /exec /exit
  45.     /file /fill /findfont /flattenpath /floor
  46.     /flush /flushfile /for /forall /ge
  47.     /get /getinterval /grestore /gsave /gstate
  48. % 80
  49.     /gt /identmatrix /idiv /idtransform /if
  50.     /ifelse /image /imagemask /index /ineofill
  51.     /infill /initviewclip /inueofill /inufill /invertmatrix
  52.     /itransform /known /le /length /lineto
  53. % 100
  54.     /load /loop /lt /makefont /matrix
  55.     /maxlength /mod /moveto /mul /ne
  56.     /neg /newpath /not /null /or
  57.     /pathbbox /pathforall /pop /print /printobject
  58. % 120
  59.     /put /putinterval /rcurveto /read /readhexstring
  60.     /readline /readstring /rectclip /rectfill /rectstroke
  61.     /rectviewclip /repeat /restore /rlineto /rmoveto
  62.     /roll /rotate /round /save /scale
  63. % 140
  64.     /scalefont /search /selectfont /setbbox /setcachedevice
  65.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  66.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  67.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  68. % 160
  69.     /show /showpage /stop /stopped /store
  70.     /string /stringwidth /stroke /strokepath /sub
  71.     /systemdict /token /transform /translate /truncate
  72.     /type /uappend /ucache /ueofill /ufill
  73. % 180
  74.     /undef /upath /userdict /ustroke /viewclip
  75.     /viewclippath /where /widthshow /write /writehexstring
  76.     /writeobject /writestring /wtranslation /xor /xshow
  77.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  78. % 200
  79.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  80.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  81.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  82.     /currentglobal /execform /filter /findresource /globaldict
  83. % 220
  84.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  85.     /setpattern
  86. % pad to 256
  87.     counttomark 256 exch sub { 0 } repeat
  88. % 256
  89.     /= /== /ISOLatin1Encoding /StandardEncoding
  90. % 260
  91.     ([) cvn (]) cvn /atan /banddevice /bytesavailable
  92.     /cachestatus /closefile /colorimage /condition /copypage
  93.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  94.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  95. % 280
  96.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  97.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  98.     /definefont /deletefile /detach /deviceinfo /dictstack
  99.     /echo /erasepage /errordict /execstack /executeonly
  100. % 300
  101.     /exp /false /filenameforall /fileposition /fork
  102.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  103.     /initmatrix /instroke /inustroke /join /kshow
  104.     /ln /lock /log /mark /monitor
  105. % 320
  106.     /noaccess /notify /nulldevice /packedarray /quit
  107.     /rand /rcheck /readonly /realtime /renamefile
  108.     /renderbands /resetfile /reversepath /rootfont /rrand
  109.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  110. % 340
  111.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  112.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  113.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  114.     /sqrt /srand /stack /status /statusdict
  115. % 360
  116.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  117.     /version /vmreclaim /vmstatus /wait /wcheck
  118.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  119.     /cleardictstack
  120. % 376
  121.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  122.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  123.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  124.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  125. % 428
  126.     /setvmthreshold (<<) cvn
  127.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  128.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  129. % 440
  130.     /glyphshow /languagelevel /product /pstack /resourceforall
  131.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  132.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  133.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  134. % 460
  135.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  136.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  137.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  138.     /Indexed /Pattern /Separation /CIEBasedDEF /CIEBasedDEFG
  139. % 480
  140.     /DeviceN
  141. % 481 -- end
  142. .packtomark
  143. dup /SystemNames exch def .installsystemnames
  144.  
  145. % Define printobject and writeobject.
  146. % These are mostly implemented in PostScript, so that we don't have to
  147. % worry about interrupts or callbacks when writing to the output file.
  148.  
  149. % Define procedures for accumulating the space required to represent
  150. % an object in binary form.
  151. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  152.   /integertype /pop load
  153.   /realtype 1 index
  154.   /marktype 1 index
  155.   /nulltype 1 index
  156.   /booleantype 1 index
  157.   /nametype { length add } bind
  158.   /stringtype 1 index
  159.   /arraytype null
  160.   /dicttype null
  161. .dicttomark def
  162. cntdict /arraytype {
  163.   dup length 4 -1 roll add 3 1 roll {
  164.     dup type //cntdict exch get exec
  165.   } forall
  166. } bind put
  167. cntdict /dicttype {
  168.   WRITEDICTS {
  169.     dup dup length 2 mul 5 -1 roll add 4 2 roll {
  170.       4 1 roll dup type //cntdict exch get exec
  171.       3 -1 roll dup type //cntdict exch get exec
  172.     } forall
  173.   } {
  174.     /writeobject load /typecheck signalerror
  175.   } ifelse
  176. } bind put
  177.  
  178. /w2dict mark
  179.   /nametype { 2 copy .writecvs pop } bind
  180.   /stringtype 1 index
  181. .dicttomark def
  182.  
  183. /.bosheader {        % <top_length> <total_length> <string8> .bosheader
  184.             %   <string4|8>
  185.   dup 0 currentobjectformat 127 add put        % object format => BOS tag
  186.   2 index 255 le 2 index 65531 le and {
  187.     % Use the short header format: tag toplen(1) totlen(2)
  188.     exch 4 add exch
  189.     0 4 getinterval
  190.     dup 1 5 -1 roll put
  191.   } {
  192.     % Use the long header format: tag 0(1) toplen(2) totlen(4)
  193.     exch 8 add exch
  194.     0 0 4 2 roll .bosobject exch pop exch pop    % store with byte swapping
  195.   } ifelse        % Stack: shortlen str
  196.   exch dup -8 bitshift exch 255 and    % str hibyte lobyte
  197.   currentobjectformat 1 and 0 eq {    % lsb first
  198.     exch
  199.   } if
  200.   2 index 3 3 -1 roll put
  201.   1 index 2 3 -1 roll put
  202. } .bind def
  203.  
  204. /.writeobjects {    % <file> <tag> <array> .writeobjects -
  205.   mark exch
  206.  
  207.     % Count the space required for refs and strings.
  208.  
  209.   dup length 0 3 -1 roll
  210.     % Stack: file tag -mark- #refs #chars array
  211.   dup 4 1 roll {
  212.       dup type /arraytype eq {
  213.       % Nested array. An element of the array is also
  214.       % an array(sub array). Push the sub array to the stack.
  215.       dup 4 1 roll
  216.       } if
  217.       dup type //cntdict exch get exec
  218.    } forall
  219.  
  220.     % Write the header.
  221.  
  222.     % Stack: file tag -mark- array1 ... array|dictN #refs #chars
  223.   counttomark 3 add -2 roll 4 1 roll
  224.     % Stack: -mark- array1 ... array|dictN tag #refs #chars file
  225.   dup counttomark 1 sub index length
  226.   4 index 3 bitshift 4 index add
  227.   (xxxxxxxx) .bosheader writestring
  228.  
  229.     % Write the objects per se.
  230.  
  231.   3 1 roll pop
  232.   counttomark 1 sub index length 3 bitshift exch
  233.   3 bitshift
  234.     % Stack: -mark- array1 ... array|dictN tag file ref# char#
  235.   counttomark 4 sub {
  236.     counttomark -1 roll dup 6 1 roll
  237.     dup type /dicttype eq {        % can't be first object
  238.       { 5 1 roll (xxxxxxxx) .bosobject
  239.     3 index exch writestring
  240.     4 -1 roll (xxxxxxxx) .bosobject
  241.     3 index exch writestring
  242.       } forall
  243.     } {
  244.       { (xxxxxxxx) .bosobject
  245.     dup 1 6 index put
  246.     3 index exch writestring
  247.     4 -1 roll pop 0 4 1 roll    % clear tag
  248.       } forall
  249.     } ifelse
  250.   } repeat
  251.  
  252.     % Write the strings and names.
  253.  
  254.   pop pop exch pop
  255.     % Stack: -mark- array1 ... array|dictN file
  256.   counttomark 1 sub {
  257.     counttomark -1 roll {
  258.         % The counting pass ensured that the keys and values
  259.         % of any dictionary must be writable objects.
  260.         % Hence, we are processing a dictionary iff
  261.         % the next-to-top stack element is not a file.
  262.       1 index type /filetype ne {
  263.     exch 2 index exch dup type //w2dict exch .knownget
  264.      { exec } { pop } ifelse pop
  265.       } if
  266.       dup type //w2dict exch .knownget { exec } { pop } ifelse
  267.     } forall
  268.   } repeat
  269.  
  270.     % Clean up.
  271.  
  272.     % Stack: -mark- file
  273.   pop pop
  274.  
  275. } odef
  276.  
  277. /printobject {        % <obj> <tag> printobject -
  278.   (%stdout) (w) file 2 index 2 index writeobject pop pop
  279. } odef
  280. /writeobject {        % <file> <obj> <tag> writeobject -
  281.   3 copy exch
  282.         % We must allocate the array in local VM
  283.         % to avoid a possible invalidaccess.
  284.   .currentglobal false .setglobal exch 1 array astore exch .setglobal
  285.   .writeobjects pop pop pop
  286. } odef
  287.  
  288. % Implement binary error message output.
  289. /.objectprinttest {        % <obj> .objectprinttest -
  290.         % This is a pseudo-operator so it will restore the stack
  291.         % if it gets an error.
  292.   0 0 2 index roll dup type //cntdict exch get exec pop pop pop
  293. } bind odef
  294. /.printerror {
  295.   $error /binary get .languagelevel 2 ge and {
  296.     currentobjectformat 0 ne {
  297.       [ /Error $error /errorname get $error /command get
  298.         % Convert the object with cvs if it isn't printable.
  299.       dup { .objectprinttest } .internalstopped {
  300.     pop 100 string cvs
  301.       } if
  302.       false ] 250 printobject
  303.     }
  304.     //.printerror    % known to be a procedure
  305.     ifelse
  306.   }
  307.   //.printerror        % known to be a procedure
  308.   ifelse
  309. } bind def
  310.  
  311. currentdict /cntdict .undef
  312. currentdict /w2dict .undef
  313.  
  314. % End of level2dict
  315.  
  316. end
  317. .setlanguagelevel
  318.